package com.pp.demo.module.user.param;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.validation.Valid;
import javax.validation.constraints.*;
import java.util.List;

@ApiModel(value = "更新用户对象", description = "")
@Data
public class UserUpdateParam {

    @ApiModelProperty(value = "用户名", example = "张三", required = true)
    @NotBlank(message = "用户名不能为空")
    private String name;

    @ApiModelProperty(value = "性别（0：男，1：女）", example = "0", required = true)
    @NotNull(message = "性别不能为空") // Integer类型非空校验用@NotNull
    @Min(value = 0, message = "性别值无效（必须为0或1）")
    @Max(value = 1, message = "性别值无效（必须为0或1）")
    private Integer sex;

    @ApiModelProperty(value = "年龄（大于等于0）", example = "20")
    @Min(value = 0, message = "年龄不能小于0")
    private Integer age; // 若年龄可选，可不加@NotNull；若必填则添加

    @ApiModelProperty(value = "角色ID列表（可选，不填则不修改角色）", example = "[1,2]")
    @Size(min = 0, message = "角色ID列表不能为空") // 允许空列表，但不能为null
    @Valid // 嵌套校验：校验列表中每个元素
    private List<@NotNull @Positive(message = "角色ID必须为正数") Long> roleIds;
}
